package com.TheyChat.service.config.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.TheyChat.service.config.core.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户来源枚举类
 */
@AllArgsConstructor
@Getter
public enum UserSourceEnum implements BaseEnum {

    /**
     * 系统新增
     */
    FROM_SYSTEM(1, "系统新增"),
    /**
     * 第三方导入
     */
    FROM_THIRD(2, "第三方系统同步");

    @EnumValue
    private final Integer value;

    private final String desc;

    /**
     * 序列化
     *
     * @return 不允许返回 null
     */
    @Override
    public Integer getValue() {
        return this.value;
    }

    @JsonCreator
    public static UserSourceEnum create(Integer value) {
        for (UserSourceEnum item : UserSourceEnum.values()) {
            if (item.value.equals(value)) {
                return item;
            }
        }
        throw new BusinessException("Incorrect enum value for UserSourceEnum: " + value);
    }

}

